var bustcachevar = false //bust potential caching of external pages after initial request? (1=yes, 0=no)
var loadedobjects = ""
var rootdomain = "http://"+window.location.hostname

function load_in(url, containerid) //  loading  data  to  div (inside)
{
  var page_request = false
  if (window.XMLHttpRequest) // if Mozilla, Safari etc
    page_request = new XMLHttpRequest()
    else if (window.ActiveXObject)
    {
      // if IE
      try
      {
        page_request = new ActiveXObject("Msxml2.XMLHTTP")
      }
      catch (e)
      {
        try
        {
          page_request = new ActiveXObject("Microsoft.XMLHTTP")
        }
        catch (e)
        {
          alert ('Error :' + e);
        }
      }
    }
    else
      return false
      page_request.onreadystatechange = function()
      {
        loadpage(page_request, containerid)
      }
      if (bustcachevar) //if bust caching of external page
      { var bustcacheparameter = (url.indexOf("?")!=-1)? "&"+new Date().getTime(): "?"+new Date().getTime()
        page_request.open('GET', url+bustcacheparameter, true);
	  }
	  else
	  {
	   page_request.open('GET', url, true);
	  }
        page_request.send(null)
}

function loadpage(page_request, containerid)
{
	if (page_request.readyState <= 3){

		document.getElementById(containerid).innerHTML = '<span class="ajax_loader">Loading data...</span>';

	}
	else if ( page_request.status==404)
	{
		document.getElementById(containerid).innerHTML = '<div class="ajax_error"><h5> Ajax(!):: Unable to load file! </h5><h6> STATUS: <b>404</b> </h6> </div>';
	}

if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
document.getElementById(containerid).innerHTML=page_request.responseText
}
